if (!jsx3.lang.Class.forName("tibco.admin.enterpriseAssets.uddi.viewEdit.UddiEdit")) jsx3.Class.defineClass(
        'tibco.admin.enterpriseAssets.uddi.viewEdit.UddiEdit', // full name of the class to create
        jsx3.gui.LayoutGrid, //  extends jsx3.lang.Object
        null, // dose not implements any interfaces
        function(uViewEdit) {
            uViewEdit.prototype.workspace = null;
            uViewEdit.prototype.success = "false";
            uViewEdit.instance = null;

            uViewEdit.getInstance = function() {
                if (!this.instance) {
                    this.instance = new tibco.admin.enterpriseAssets.uddi.viewEdit.UddiEdit();
                }
                return this.instance;
            }

            uViewEdit.prototype.subscribeAll = function() {
                this.clearDetails();
                var me = this;
                tibco.admin.PubSub.subscribe(tibco.admin.enterpriseAssets.sReg.uddi.EventID.UDDI_SELECTED, me, me.populateDetails);
                tibco.admin.PubSub.subscribe(tibco.admin.enterpriseAssets.sReg.uddi.EventID.ADD_IN_PROGRESS, me, me.tryToAdd);
                tibco.admin.PubSub.subscribe(tibco.admin.enterpriseAssets.sReg.uddi.EventID.UDDI_DELETED, me, me.clearDetails);
                this.addMode = false;
                this.passedItems = {};
            }

            uViewEdit.prototype.doUnsubscribeAll = function() {
                var me = this;
                tibco.admin.PubSub.unsubscribe(tibco.admin.enterpriseAssets.sReg.uddi.EventID.UDDI_SELECTED, me, me.populateDetails);
                tibco.admin.PubSub.unsubscribe(tibco.admin.enterpriseAssets.sReg.uddi.EventID.ADD_IN_PROGRESS, me, me.tryToAdd);
                tibco.admin.PubSub.unsubscribe(tibco.admin.enterpriseAssets.sReg.uddi.EventID.UDDI_DELETED, me, me.clearDetails);
            }

            uViewEdit.prototype.populateDetails = function(msg) {
                this.setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                if (this.handler && this.handler.isInEditMode()) {
                    return;
                }
                this.entityID = msg.entityID;
                this.passedItems = {};
                this.getDescendantOfName("btnEditUddi_23").setEnabled(jsx3.gui.Form.STATEENABLED, true);

                this.getDescendantOfName("lblUDDIName_23", true, false).setText(msg.name, true);
                this.getDescendantOfName("txtUDDIName_23", true, false).setValue(msg.name);

                this.getDescendantOfName("lblUDDIDescription_23", true, false).setText(msg.description, true);
                this.getDescendantOfName("txtUDDIDescription_23", true, false).setValue(msg.description);

                this.getDescendantOfName("lblInquiryURL_23", true, false).setText(msg.inquiryURL, true);
                this.getDescendantOfName("txtInquiryURL_23", true, false).setValue(msg.inquiryURL);

                this.getDescendantOfName("lblPublishURL_23", true, false).setText(msg.publishURL, true);
                this.getDescendantOfName("txtPublishURL_23", true, false).setValue(msg.publishURL);

                this.getDescendantOfName("lblUsername_23", true, false).setText(msg.userName, true);
                this.getDescendantOfName("txtUsername_23", true, false).setValue(msg.userName);

                this.getDescendantOfName("lblPassword_23", true, false).setText("<i>Hidden</i>", true);
                this.getDescendantOfName("txtPassword_23", true, false).setValue(msg.password);

                this.getDescendantOfName("lblAuthModel_23", true, false).setText(tibco.admin.Main.getServer().getDynamicProperty("@lblBasic23"), true);
                if (msg.useProxy == "true") {
                    this.getDescendantOfName("lblUseProxy_23", true, false).setText("Yes", true);
                    this.getDescendantOfName("rdoYProxy23", true, false).setSelected(jsx3.gui.RadioButton.SELECTED);
                    this.getDescendantOfName("rdoNProxy23", true, false).setSelected(jsx3.gui.RadioButton.UNSELECTED);
                    this.getDescendantOfName("blkProxyDetails23").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true)
                }
                else {
                    this.getDescendantOfName("lblUseProxy_23", true, false).setText("No", true);
                    this.getDescendantOfName("rdoYProxy23", true, false).setValue(jsx3.gui.RadioButton.UNSELECTED);
                    this.getDescendantOfName("rdoNProxy23", true, false).setValue(jsx3.gui.RadioButton.SELECTED);
                    this.getDescendantOfName("blkProxyDetails23").setDisplay(jsx3.gui.Block.DISPLAYNONE, true)
                }

                this.getDescendantOfName("lblProxyUsername_23", true, false).setText(msg.proxyUserName, true);
                this.getDescendantOfName("txtProxyUsername_23", true, false).setValue(msg.proxyUserName);

                this.getDescendantOfName("lblProxyHost_23", true, false).setText(msg.proxyHost, true);
                this.getDescendantOfName("txtProxyHost_23", true, false).setValue(msg.proxyHost);

                this.getDescendantOfName("lblProxyPort_23", true, false).setText(msg.proxyPort, true);
                this.getDescendantOfName("txtProxyPort_23", true, false).setValue(msg.proxyPort);

                this.getDescendantOfName("lblProxyPassword_23", true, false).setText(msg.proxyPassword, true);
                this.getDescendantOfName("txtProxyPassword_23", true, false).setValue(msg.proxyPassword);
            }

            uViewEdit.prototype.clearDetails = function() {
                this.setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                this.getDescendantOfName("btnSaveUddi_23", true, false).setEnabled(jsx3.gui.Form.STATEENABLED, true).
                        setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                this.getDescendantOfName("btnEditUddi_23", true, false).setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true)
                        .setEnabled(jsx3.gui.Form.STATEDISABLED, true);
                this.getDescendantOfName("btnCancelUddi_23", true, false).setDisplay(jsx3.gui.Block.DISPLAYNONE, true)
                var textboxes = this.getDescendantsOfType(jsx3.gui.TextBox, false);
                for (var i = 0; i < textboxes.length; i++) {
                    textboxes[i].setDisplay(jsx3.gui.Block.DISPLAYNONE, true).setValue("");
                    if (textboxes[i].getColor() == "yellow")
                        textboxes[i].setColor("#FFFFFF")
                    if (textboxes[i].getName() == "txtInquiryURL_23") {
                        textboxes[i].setValue(tibco.admin.Main.getServer().getDynamicProperty("@lblDefaultInquiryURL23"));
                    }
                    else
                        if (textboxes[i].getName() == "txtPublishURL_23") {
                            textboxes[i].setValue(tibco.admin.Main.getServer().getDynamicProperty("@lblDefaultPublishURL23"));
                        }
                    textboxes[i].getParent().getChild(1).setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true).setText("", true);
                }

                var radios = this.getDescendantsOfType(jsx3.gui.RadioButton, false);
                for (var i = 0; i < radios.length; i++) {
                    radios[i].setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    if (radios[i].getName() == "rdoNProxy23")
                        radios[i].setSelected(jsx3.gui.RadioButton.SELECTED);
                }
                this.getDescendantOfName("lblAuthModel_23").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true).setText("", true);
                this.getDescendantOfName("lblUseProxy_23").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true).setText("", true);
            }

            uViewEdit.prototype.tryToAdd = function() {
                this.passedItems = {"txtUDDIName_23":false,
                    "txtInquiryURL_23":true,
                    "txtPublishURL_23":true,
                    "txtUsername_23":false};
                this.addMode = true;
                this.clearDetails();
                this.setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                this.editModeOn(true);
                this.showEditPanel(false);
                this.getDescendantOfName("txtUDDIName_23").setEnabled(jsx3.gui.Form.STATEENABLED, true).focus();
                this.getDescendantOfName("lblAuthModel_23").setText(tibco.admin.Main.getServer().getDynamicProperty("@lblBasic23"), true).focus();
                this.getDescendantOfName("btnSaveAdd_23").setEnabled(jsx3.gui.Form.STATEDISABLED, true);
            }

            uViewEdit.prototype.endAdd = function(saved, newEntityID) {
                this.showEditPanel(true);
                this.addMode = false;
                this.editModeOn(false);
                if (!saved) {
                    this.clearDetails();
                }
                else {
                    this.saveDetails();
                    this.getDescendantOfName("btnEditUddi_23").setEnabled(jsx3.gui.Form.STATEENABLED, true);
                }
                this.getDescendantOfName("txtUDDIName_23").setEnabled(jsx3.gui.Form.STATEDISABLED, true);
                var msg = new Object();
                msg.subject = tibco.admin.enterpriseAssets.sReg.uddi.EventID.ADD_OVER;
                msg.entityID = newEntityID;
                tibco.admin.PubSub.publish(msg);
            }

            uViewEdit.prototype.saveDetails = function() {
                var textboxes = this.getDescendantsOfType(jsx3.gui.TextBox, false);
                for (var i = 0; i < textboxes.length; i++) {
                    textboxes[i].getParent().getChild(1).setText(textboxes[i].getValue(), true);
                }
                if (this.getDescendantOfName("rdoYProxy23").getSelected() == jsx3.gui.RadioButton.SELECTED) {
                    this.getDescendantOfName("lblUseProxy_23").setText("Yes", true);
                }
                else {
                    this.getDescendantOfName("lblUseProxy_23").setText("No", true);
                }
            }

            uViewEdit.prototype.calleditUDDIServerRegisteredWithEnterprise = function() {
                var objService = tibco.admin.Main.loadService("tibco.admin",
                        "tibco/admin/enterpriseAssets/sReg/uddi/viewEdit/rules/editUDDIServerRulesBasic.xml",
                        "editUDDIServerRegisteredWithEnterprise",
                        "Edit UDDI Servers Registered With Enterprise");
                objService.useProxy = (this.getDescendantOfName("rdoYProxy23").getSelected() == jsx3.gui.RadioButton.SELECTED);
                objService.entityID = this.entityID;

                var me = this
                objService.subscribe(jsx3.net.Service.ON_SUCCESS, me, me.oneditUDDIServerRegisteredWithEnterpriseSuccess);
                objService.setEndpointURL(tibco.admin.util.ServiceHelper.getUddiServerEndpointURL());
                objService.doCall();
            };

            uViewEdit.prototype.oneditUDDIServerRegisteredWithEnterpriseSuccess = function(objEvent) {
                this.saveDetails();
                this.editModeOn(false);
                var msg = new Object();
                msg.subject = tibco.admin.enterpriseAssets.sReg.uddi.EventID.UDDI_REFRESH;
                tibco.admin.PubSub.publish(msg);
            };

            uViewEdit.prototype.callregisterUDDIServerWithEnterprise = function() {
                var objService = tibco.admin.Main.loadService("tibco.admin",
                        "tibco/admin/enterpriseAssets/sReg/uddi/viewEdit/rules/registerUddiServerRulesBasic.xml",
                        "registerUDDIServerWithEnterprise",
                        "Register UDDI Servers With Enterprise");
                objService.useProxy = (this.getDescendantOfName("rdoYProxy23").getSelected() == jsx3.gui.RadioButton.SELECTED);
                objService.entityID = this.entityID;
                //subscribe and call
                var me = this;
                objService.subscribe(jsx3.net.Service.ON_SUCCESS, me, me.onregisterUDDIServerWithEnterpriseSuccess);
                objService.setEndpointURL(tibco.admin.util.ServiceHelper.getUddiServerEndpointURL());
                objService.doCall();
            };

            uViewEdit.prototype.onregisterUDDIServerWithEnterpriseSuccess = function(objEvent) {
                if (objEvent.target.success == "true")
                {
                    this.endAdd(true, objEvent.target.entityID);
                }
            };

            uViewEdit.prototype.showEditPanel = function(toShow) {
                if (!toShow) {
                    this.getDescendantOfName("blkEdit23").setDisplay(jsx3.gui.Block.DISPLAYNONE, true)
                            .getParent().getChild("blkAdd23").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    this.getDescendantOfName("paneButton23").repaint();
                }
                else {
                    this.getDescendantOfName("blkEdit23").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true)
                            .getParent().getChild("blkAdd23").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    this.getDescendantOfName("paneButton23").repaint();
                }
            }

            uViewEdit.prototype.editModeOn = function(on) {
                if (on) {
                    this.handler.beginEdit();
                }
                else {
                    this.handler.endEdit();
                }
                    var todisplay, tonotdisplay;
                if (on) {
                    todisplay = jsx3.gui.Block.DISPLAYBLOCK;
                    tonotdisplay = jsx3.gui.Block.DISPLAYNONE;

                    msg = new Object();
                    msg.subject = tibco.admin.enterpriseAssets.sReg.uddi.EventID.DISABLED_REFRESH;
                    tibco.admin.PubSub.publish(msg);

                }
                else {
                    todisplay = jsx3.gui.Block.DISPLAYNONE;
                    tonotdisplay = jsx3.gui.Block.DISPLAYBLOCK;
                    msg = new Object();
                    msg.subject = tibco.admin.enterpriseAssets.sReg.uddi.EventID.ENABLED_REFRESH;
                    tibco.admin.PubSub.publish(msg);
                }
                this.getDescendantOfName("btnSaveUddi_23").setDisplay(todisplay, true)
                        .getParent().getChild("btnCancelUddi_23").setDisplay(todisplay, true)
                        .getParent().getChild("btnEditUddi_23").setDisplay(tonotdisplay, true)
                    var textboxes = this.getDescendantsOfType(jsx3.gui.TextBox, false);
                    for (var i = 0; i < textboxes.length; i++) {
                        textboxes[i].setDisplay(todisplay, true);
                    textboxes[i].getParent().getChild(1).setDisplay(tonotdisplay, true);
                    }
                    var radios = this.getDescendantsOfType(jsx3.gui.RadioButton, false);
                for (var i = 0; i < radios.length; i++) {
                    radios[i].setDisplay(todisplay, true);
                    radios[i].getParent().getChild(1).setDisplay(tonotdisplay, true);
                }
                //this portion added for the case when the user changes radio button and then cancels

                var proxyLabel = this.getDescendantOfName("lblUseProxy_23");
                    if (proxyLabel.getText() == "Yes") {
                        this.toggleProxyServer(true);
                        proxyLabel.getParent().getChild(2).setSelected(jsx3.gui.RadioButton.SELECTED);
                    proxyLabel.getParent().getChild(3).setSelected(jsx3.gui.RadioButton.UNSELECTED);
                    }
                else {
                        this.toggleProxyServer(false);
                        proxyLabel.getParent().getChild(2).setSelected(jsx3.gui.RadioButton.UNSELECTED);
                    proxyLabel.getParent().getChild(3).setSelected(jsx3.gui.RadioButton.SELECTED);
                    }
            }

            uViewEdit.prototype.toggleProxyServer = function(bool) {
                this.getDescendantOfName("blkProxyDetails23").setDisplay(bool?jsx3.gui.Block.DISPLAYBLOCK:jsx3.gui.Block.DISPLAYNONE, true);
                if (!bool) {
                    this.passedItems["txtProxyHost_23"] = true;
                    this.passedItems["txtProxyPort_23"] = true;
                    this.passedItems["txtProxyUsername_23"] = true;
                    this.enableSaveBtn();
                }
                else {
                    if (this.getDescendantOfName("txtProxyHost_23").getValue() == "" ||
                        this.getDescendantOfName("txtProxyPort_23").getValue() == "" ||
                        this.getDescendantOfName("txtProxyUsername_23").getValue() == "") {
                        this.getDescendantOfName(this.addMode?"btnSaveAdd_23":"btnSaveUddi_23").setEnabled(jsx3.gui.Form.STATEDISABLED, true);
                        if (this.getDescendantOfName("txtProxyHost_23").getValue() == "")
                            this.passedItems["txtProxyPort_23"] = false;
                        if (this.getDescendantOfName("txtProxyPort_23").getValue() == "")
                            this.passedItems["txtProxyHost_23"] = false;
                        if (this.getDescendantOfName("txtProxyUsername_23").getValue() == "")
                            this.passedItems["txtProxyUsername_23"] = false;
                    }
                }

            }

            uViewEdit.prototype.validateField = function(obj, strValue) {
                this.passedItems[obj.getName()] = tibco.admin.util.Validation.doValidateNotEmptyNoWhSpace(obj, strValue);
                this.enableSaveBtn();
            }

            uViewEdit.prototype.enableSaveBtn = function() {
                var allPassed = true;
                for (var item in this.passedItems) {
                    if (!this.passedItems[item]) allPassed = false;
                }
                if (allPassed) {
                    this.getDescendantOfName(this.addMode?"btnSaveAdd_23":"btnSaveUddi_23").setEnabled(jsx3.gui.Form.STATEENABLED, true);
                }
                else {
                    this.getDescendantOfName(this.addMode?"btnSaveAdd_23":"btnSaveUddi_23").setEnabled(jsx3.gui.Form.STATEDISABLED, true);
                }
            }

        }
        )
